package com.gong.service.user;

import com.gong.mapper.user.UserMapper;
import com.gong.mapper.user.UserMapperImpl;
import com.gong.pojo.User;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: UserServiceImpl
 * @Description: TODO
 * @Author: 。。。
 * @Data: 2021/10/209:01
 * @Version: 1.0
 **/
public class UserServiceImpl implements UserService {
	private UserMapper userMapper = new UserMapperImpl();

	@Override
	public User getLoginUser(String userCode) {
		return userMapper.getLoginUser(userCode);
	}

	@Override
	public boolean updateUserPassword(int id, String password) {
		boolean flag = false;

		if (userMapper.updateUserPassword(id, password) > 0) {
			flag = true;
			return flag;
		} else {
			return flag;
		}
	}

	@Override
	public int getUserCount(String userName, int userRole) {
		return userMapper.getUserCount(userName, userRole);

	}

	@Override
	public List<User> getUserList(String userName, int userRole, int currentPageNo, int pageSize) {
		List<User> userList = new ArrayList<>();

		currentPageNo = (currentPageNo - 1) * pageSize;

		return userMapper.getUserList(userName, userRole, currentPageNo, pageSize);
	}


	//@Test
	//public void test() {
	//	List<User> userList = this.getUserList(null, 0, 1, 20);
	//	for (User user : userList) {
	//		System.out.println(user.getUsername());
	//	}
	//}
}
